import { IPSCodeList } from '../../codelist/ipscode-list';
import { PSControlObjectImpl } from '../pscontrol-object-impl';
import { IPSDEChartDataSetField } from './ipsdechart-data-set-field';

export class PSDEChartDataSetFieldImpl extends PSControlObjectImpl implements IPSDEChartDataSetField {
  get groupMode(): string {
    return this.M.groupMode;
  }

  get index(): number {
    return this.M.index;
  }

  protected pscodelist: IPSCodeList | null = null;

  getPSCodeList(): IPSCodeList | null {
    if (this.pscodelist != null) return this.pscodelist;
    const value = this.M.getPSCodeList;
    if (value == null) {
      return null;
    }
    this.pscodelist = this.getPSModel4('codelist.IPSCodeList', value, 'getPSCodeList') as IPSCodeList;
    return this.pscodelist;
  }

  get psCodeList(): IPSCodeList | null {
    return this.getPSCodeList();
  }

  getPSCodeListMust(): IPSCodeList {
    const value = this.getPSCodeList();
    if (value == null) {
      throw new Error('未指定代码表对象');
    }
    return value;
  }

  get groupField(): boolean {
    return this.M.groupField;
  }

  get cls(): string {
    return 'PSDEChartDataSetFieldImpl';
  }

  instanceof(cls: string): boolean {
    if (cls == 'control.chart.IPSChartDataSetField' || cls == 'control.chart.IPSDEChartDataSetField') return true;
    return super.instanceof(cls);
  }
}
